package com.smartHome.mapper;

import com.smartHome.pojo.entity.SceneDevice;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SceneDeviceMapper {
    @Select("select * from  scene_devices where scene_id = #{sceneId}")
    List<SceneDevice> getSceneDeviceList(Integer sceneId);

    @Update("UPDATE scene_devices SET status = #{status}, update_time = NOW() " +
            "WHERE scene_device_id = #{sceneDeviceId}")
    void updateStatus(@Param("sceneDeviceId") Integer sceneDeviceId, 
                     @Param("status") Integer status);

    @Insert("insert into scene_devices(scene_id, device_id, device_name,status,create_time, update_time) " +
            "values(#{sceneId}, #{deviceId},#{deviceName},#{status}, now(), now())")
    void addSceneDevice(SceneDevice sceneDevice);

    @Delete("DELETE from scene_devices where scene_id = #{sceneId}")
    void deleteSceneDevice(Integer sceneId);
}
